import { reqAddressInfo, reqOrderInfo } from "@/api"

const state = {
    address: {},
    orderinfo: {}
}
const mutations = {
    // 储存用户地址信息
    GETUSERADDRESS(state, address) {
        state.address = address
    },
    // 存储用户清单信息
    GETORDERINFO(state, orderinfo) {
        state.orderinfo = orderinfo
    }
}
const actions = {
    // 获取用户地址信息
    async getUserAddress({ commit }) {
        let res = await reqAddressInfo()
        if (res.code = 200) {
            commit('GETUSERADDRESS', res.data)
        }
    },
    // 获取商品清单
    async getOrderInfo({ commit }) {
        let res = await reqOrderInfo()
        console.log(res);
        if (res.code == 200) {
            commit('GETORDERINFO', res.data)
        }
    }
}
const getters = {}
export default {
    state,
    mutations,
    actions,
    getters
}